﻿using SkiaSharp;
using System;
using System.IO;

namespace SkiaSharpConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            var info = new SKImageInfo(256, 256);
            using (var surface = SKSurface.Create(info))
            {
                var canvas = surface.Canvas;

                var paint = new SKPaint
                {
                    Color = SKColors.Red,
                    IsAntialias = true,
                    Style = SKPaintStyle.StrokeAndFill,
                    TextAlign = SKTextAlign.Center,
                    TextSize = 24
                };

                var coord = new SKPoint(info.Width / 2, (info.Height + paint.TextSize) / 2);

                canvas.DrawText("Hello Word!", coord, paint);

                using (var fileStream = File.OpenWrite(DateTime.Now.Ticks.ToString() + ".png"))
                {
                    using (var image = surface.Snapshot())
                    {
                        image.Encode(SKEncodedImageFormat.Png, 100).SaveTo(fileStream);
                    }
                }
            }
        }
    }
}
